package com.sunnyebuy.merchant.dao.impl;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.stereotype.Repository;

import com.sunnyebuy.merchant.dao.CountryDAO;
import com.sunnyebuy.merchant.dao.MerchantBaseDAO;

/**
 * <p>
 * Title: CountryDAOImpl.java
 * </p>
 * 
 * <p>
 * Description: com.sunnyebuy.merchant.dao.impl
 * </p>
 * 
 * <p>
 * Copyright: Copyright (c) 2008-2011 All rights reserved.
 * </p>
 * 
 * <p>
 * Created: 2011-12-28 上午11:11:17
 * </p>
 * 
 * @author Wenzhong Gu
 * 
 * @version 1.0
 */
@Repository(value = "countryDAO")
public class CountryDAOImpl extends MerchantBaseDAO implements CountryDAO {

	@Override
	public List<?> findAllCountries() {
		return this.getHibernateTemplate().execute(new HibernateCallback<List<?>>() {
			@Override
			public List<?> doInHibernate(Session session) throws HibernateException, SQLException {
				String hql = "SELECT model.countryAbbreviation,model.countryEnglishName FROM Country model ORDER BY model.countryAbbreviation";
				return session.createQuery(hql).list();
			}
		});
	}
}